package com.aliothservice.catfish.order.data;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import org.springframework.data.annotation.Id;

public class Review {
	
	public Map<String, Object> toMap() {
		Map<String, Object> map = new HashMap<String, Object>();
		
		if (this.getBuyerPhoneNumber().length() != 11) {
			map.put("buyerPhoneNumber", this.getBuyerPhoneNumber());
		} else {
			String maskedPhoneNumber = String.format("%s*****%s", this.getBuyerPhoneNumber().substring(0, 2), this.getBuyerPhoneNumber().substring(7, 10));
			map.put("buyerPhoneNumber", maskedPhoneNumber);
		}
		map.put("orderId", this.getOrderId());
		map.put("starCount", this.getStarCount());
		map.put("reviewContent", this.getReviewContent());
		map.put("photoId", this.getPhotoId());
		DateFormat fullFormatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");
		map.put("creationDate", fullFormatter.format(this.getCreationDate()));
		if (null != this.getLicensePlate()) {
			map.put("licensePlate", this.getLicensePlate());
			map.put("routeOrigin", this.getRouteOrigin());
			map.put("routeDestination", this.getRouteDestination());
		}
		if (null != this.getWarehouseName()) {
			map.put("warehouseName", this.getWarehouseName());
			map.put("warehouseAddress", this.getWarehouseAddress());
		}
		if (null != this.getProductTitle()) {
			map.put("productTitle", this.getProductTitle());
			map.put("productOrigin", this.getProductOrigin());
		}
		
		return map;
	}
	
	@Id
	private String id;
	
	private String userId;
	
	private String buyerPhoneNumber;
	
	private String orderId;
	private Integer starCount;
	private String reviewContent;
	
	// vehicle
	private String licensePlate;
	private String routeOrigin;
	private String routeDestination;
	
	// warehouse
	private String warehouseName;
	private String warehouseAddress;
	
	// product
	private String productTitle;
	private String productOrigin;
	
	private String photoId;
	private Date creationDate;

	public String getUserId() {
		return userId;
	}

	public void setUserId(String userId) {
		this.userId = userId;
	}

	public String getOrderId() {
		return orderId;
	}

	public void setOrderId(String orderId) {
		this.orderId = orderId;
	}

	public Integer getStarCount() {
		return starCount;
	}

	public void setStarCount(Integer starCount) {
		this.starCount = starCount;
	}

	public String getReviewContent() {
		return reviewContent;
	}

	public void setReviewContent(String reviewContent) {
		this.reviewContent = reviewContent;
	}

	public Date getCreationDate() {
		return creationDate;
	}

	public void setCreationDate(Date creationDate) {
		this.creationDate = creationDate;
	}

	public String getBuyerPhoneNumber() {
		return buyerPhoneNumber;
	}

	public void setBuyerPhoneNumber(String buyerPhoneNumber) {
		this.buyerPhoneNumber = buyerPhoneNumber;
	}

	public String getLicensePlate() {
		return licensePlate;
	}

	public void setLicensePlate(String licensePlate) {
		this.licensePlate = licensePlate;
	}

	public String getRouteOrigin() {
		return routeOrigin;
	}

	public void setRouteOrigin(String routeOrigin) {
		this.routeOrigin = routeOrigin;
	}

	public String getRouteDestination() {
		return routeDestination;
	}

	public void setRouteDestination(String routeDestination) {
		this.routeDestination = routeDestination;
	}

	public String getPhotoId() {
		return photoId;
	}

	public void setPhotoId(String photoId) {
		this.photoId = photoId;
	}

	public String getWarehouseName() {
		return warehouseName;
	}

	public void setWarehouseName(String warehouseName) {
		this.warehouseName = warehouseName;
	}

	public String getWarehouseAddress() {
		return warehouseAddress;
	}

	public void setWarehouseAddress(String warehouseAddress) {
		this.warehouseAddress = warehouseAddress;
	}

	public String getProductTitle() {
		return productTitle;
	}

	public void setProductTitle(String productTitle) {
		this.productTitle = productTitle;
	}

	public String getProductOrigin() {
		return productOrigin;
	}

	public void setProductOrigin(String productOrigin) {
		this.productOrigin = productOrigin;
	}

}
